<?php defined('InNcPHP') or exit('Access Invalid!');?>

<script src="<?php echo RESOURCE_URL;?>/css/diyUpload/js/jquery.js"></script>

<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_URL;?>/css/diyUpload/css/webuploader.css">
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_URL;?>/css/diyUpload/css/diyUpload.css?v=0.04">
<script type="text/javascript" src="<?php echo RESOURCE_URL;?>/css/diyUpload/js/webuploader.html5only.min.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_URL;?>/css/diyUpload/js/diyUpload.js?v=0.011"></script>


<style>
    .album{width: 100%;  clear: both;  padding-top: 10px;  overflow: hidden;}
    .album ul li img{width: 120px;height: 120px;}
    .item{background-color: #F5F5F5;  width: 100px;  height: 100px;  display: block;  border: 1px solid #DDDDDD;  margin: 5px 15px 5px 0px;  position: relative;  float: left;  text-align: center;}
    .item img{position: absolute;width: 90px;height: 90px;}
    #box,#box1,#box2{ margin:20px; width:540px; min-height:120px; background:#f1f1f1}
    .title h1{line-height: 40px;color: #5a5a5a;font-size: 16px;margin: 10px;}
    .pic-list{margin-top: 20px;font-size: 0;}
    .pic-list li{display: inline-block;margin: 0 18px;width: 120px;height: 120px;border: 1px solid #e1e1e1}
    .pic-list li img{width: 100%;  height: 100%;  overflow: hidden ;}
    .pic-list li span{display: inline-block;height: 20px;width: 20px;text-align: center;line-height: 17px;font-size: 16px;background-color: rgba(0,0,0,0.4);border-radius: 50%;color: #fff;position: absolute;margin-top: -10px;margin-left: -10px;cursor: pointer;}
</style>
<body>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <h3>酒店</h3>
            <?php echo $output['top_link'];?>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <?php echo $output['sub_link'];?>
    <div style="clear: both;"></div>
    <form id="add_form" method="post" enctype="multipart/form-data">

        <ul class="pic-list">
            <h1>外观图册</h1>
            <?php foreach ($output['images'] as $item){?>
                <?php if($item['cate']==1):?>
                <li><img src="<?php echo $item['img_path']?>"><span class="delete" data-pi_id="<?php echo $item['img_id'];?>">x</span></li>
                <?php  endif; ?>
            <?php }?>
        </ul>
        <ul class="pic-list">
            <h1>大厅图册</h1>
            <?php foreach ($output['images'] as $item){?>
                <?php if($item['cate']==2):?>
                <li><img src="<?php echo $item['img_path']?>"><span class="delete" data-pi_id="<?php echo $item['img_id'];?>">x</span></li>
                <?php endif;?>
            <?php }?>
        </ul>
        <ul class="pic-list">
            <h1>餐厅图册</h1>
            <?php foreach ($output['images'] as $item){?>
                <?php if($item['cate']==3):?>
                <li><img src="<?php echo $item['img_path']?>"><span class="delete" data-pi_id="<?php echo $item['img_id'];?>">x</span></li>
                <?php endif; ?>
            <?php }?>
        </ul>
        <div class="title">
            <div class="wrapper">
                <h1>外观</h1><div class="vatop tips">图片尺寸：800*800 ； 可上传格式：gif,jpg,png </div>
              </div>
        </div>

        <input type="hidden" name="form_submit" value="ok" />
        <input type="hidden" name="goods_id" id="goods_id" value="<?php echo $output['goods_id']?>">
        <div id="box">
            <div id="test" ></div>
        </div>
        <h1>大厅</h1><div class="vatop tips">图片尺寸：800*800 ； 可上传格式：gif,jpg,png </div>
        <div id="box1">
            <div id="test1" ></div>
        </div>
        <h1>餐厅</h1><div class="vatop tips">图片尺寸：800*800 ； 可上传格式：gif,jpg,png </div>
        <div id="box2">
            <div id="test2" ></div>
        </div>
        <a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit'];?></span></a>
    </form>
</div>
</body>
<script>

    $(function () {

        $("#submitBtn").click(function(){
            $("#add_form").submit();
        });

        $('.delete').click(function () {
            var pi_id = $(this).attr('data-pi_id');
            //var img_li = $(this).parent("li");


            layer.confirm('确定要删除该图片吗?', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.ajax({
                    type:'post',
                    url:'index.php?act=common&op=all_delimg',
                    data:{img_id:pi_id},
                    dataType:'json',
                    success:function(data){
                        if(data.res) {
//                            img_li.hide();
                            layer.msg('删除成功',{icon: 1});
                            setTimeout(function(){window.location.reload()}, 500);
                        }else{
                            layer.msg('删除失败',{icon: 5});
                            return;
                        }
                    }
                });
            }, function(){

            });


        });
    });
    //外观
    $('#test').diyUpload({
        url:'index.php?act=goodsfileupload&op=index',
        success:function( data ) {
            console.info( data );
            inputhtml="<input type='hidden' class='imagehidden' name='images_facade[]' value='"+data.result+"'>";
            $('#test').next().append(inputhtml);
        },
        error:function( err ) {
            console.info( err );
        },
        buttonText : '选择文件',
        chunked:true,
        // 分片大小
        chunkSize:512 * 1024,
        //最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
        fileNumLimit:6,
        fileSizeLimit:100000 * 1024,
        fileSingleSizeLimit:10000 * 1024,
        accept: {}
    });
    //大厅
    $('#test1').diyUpload({
        url:'index.php?act=goodsfileupload&op=index',
        success:function( data ) {
            console.info( data );
            inputhtml="<input type='hidden' class='imagehidden' name='images_lobby[]' value='"+data.result+"'>";
            $('#test').next().append(inputhtml);
        },
        error:function( err ) {
            console.info( err );
        },
        buttonText : '选择文件',
        chunked:true,
        // 分片大小
        chunkSize:512 * 1024,
        //最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
        fileNumLimit:6,
        fileSizeLimit:100000 * 1024,
        fileSingleSizeLimit:10000 * 1024,
        accept: {}
    });
    $('#test2').diyUpload({
        url:'index.php?act=goodsfileupload&op=index',
        success:function( data ) {
            console.info( data );
            inputhtml="<input type='hidden' class='imagehidden' name='images_dining[]' value='"+data.result+"'>";
            $('#test').next().append(inputhtml);
        },
        error:function( err ) {
            console.info( err );
        },
        buttonText : '选择文件',
        chunked:true,
        // 分片大小
        chunkSize:512 * 1024,
        //最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
        fileNumLimit:6,
        fileSizeLimit:100000 * 1024,
        fileSingleSizeLimit:10000 * 1024,
        accept: {}
    });


</script>
